package com.yst.webplugin.additional.mask;



import com.yst.web.utils.ClassUtils;

import java.util.Objects;

public class MaskEmail implements IStringMask {

    public static final String defaultEmail="****@**.**";

    @Override
    public String make(String source) {
        if (Objects.isNull(source)) return defaultEmail;
        int index=source.indexOf('@');
        if (index<0) return defaultEmail;
        String prefix=source.substring(0,index);
        try {
            prefix = ClassUtils.getSingletonObject(MaskName.class).make(prefix);
            return prefix.concat(source.substring(index));
        }
        catch (Exception e){
            return defaultEmail;
        }
    }
}
